var Action = require("../apiaction");
var Utility = require("../Utility/utility.js");
exports.roleAPI = function(router){

    //获取权限组列表
    router.all('/role/getrolelist',function(req,res){

        var params ={mobile: req.param("name")};
        params = Utility.get_list_page_size_param(req,params);

        Action.send(req, res,"/role/getrolelist",params,function(res,data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //添加角色名
    router.all('/role/newRole',function(req,res){

        var params ={role_name: req.param("role_name")};
        params = Utility.get_list_page_size_param(req,params);

        Action.send(req, res,"/role/newRole",params,function(res,data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    // 删除角色
    router.all('/role/deleterole',function(req,res) {

        var params = {role_id: req.param("role_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/role/deleterole", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });


    });

    // 更新角色名
    router.all('/role/updaterole',function(req,res) {

        var params = {role_id: req.param("role_id"),role_name: req.param("role_name")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/role/updaterole", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });


    });


    //getmenuinfo
    router.all('/role/getmenuinfo',function(req,res) {

        var params = {role_id: req.param("role_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/role/getmenuinfo", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });


    });

    //getmenuinfo
    router.all('/role/setmenuinfo',function(req,res) {

        var params = {role_id: req.param("role_id"),select_list: req.param("select_list"),unselect_list: req.param("unselect_list")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/role/setmenuinfo", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });


    });




}
